

typedef enum{
	Ts_Scan_Enable=0,
	Ts_Scan_Fully_Disable,
	Ts_Scan_Partly_Disable,
	Ts_Scan_Eable_Flag_End
}TS_USE_STATE;


extern void Ts_Scan_Use_State_Set( TS_USE_STATE Flag);

#if D_TOUCHKEY_AD

#if 0

#define TOURCH_PANEL_Y_POSITIVE			PB_ODR4
#define TOURCH_PANEL_Y_NEGATIVE			PB_ODR5

#define TOURCH_PANEL_X_POSITIVE			PB_ODR2
#define TOURCH_PANEL_X_NEGATIVE			PB_ODR3


#define TOURCH_PANEL_X_P_AD				AIN5
#define TOURCH_PANEL_Y_P_AD				AIN3
//////////////////////////////////////////////////////////////////////
//			DDR		CR1		CR2
//			  0		 0		  0		Input	Floating without interrupt
//			  0		 1		  0		Input	Pull-up without  interrupt
//			  0		 0		  1		Input	Floating with interrupt
//			  0		 1		  1		Input	Pull-up with interrupt

//			DDR		CR1		CR2
//			  1		 0		  0		Output	Open Drain Output		
//			  1		 1		  0		Output	Push Pull Output	
//			  1		 X		  1		Output	Output speed limited to 10 MHz
//			  X		 X		  X		Output	True Open Drain
////XL		PB2 
////XH 		PB3
////YL 		PB4
////YH		PB5

////new:
////XH		PB2 
////XL 		PB3
////YH 		PB4
////YL		PB5

///////////////////////////////////////////////////////////////////////////

//Y_ADC input  X_ADC output
#define  Y_ADC_ENABLE()	{PB_DDR3=IO_AS_INPUT; \
					PB_CR13=0;PB_CR23=0;\
					PB_DDR2=IO_AS_INPUT;\
					PB_CR12=0;PB_CR22=0;\
				}

//x_ADC input  y_ADC output
#define X_ADC_ENABLE()	{PB_DDR5=IO_AS_INPUT; \
					PB_CR15=0;PB_CR25=0;\
					PB_DDR4=IO_AS_INPUT;\
					PB_CR14=0;PB_CR24=0;\
				}

//X_GPIO output  Y_GPIO input
#define Y_GPIO_STANDBY()	{PB_DDR4=IO_AS_OUTPUT;\
					PB_CR14=1;PB_CR24=0; \
					TOURCH_PANEL_Y_POSITIVE=1; \
					PB_DDR5=IO_AS_OUTPUT;\
					PB_CR15=0;PB_CR25=0; \
					TOURCH_PANEL_Y_NEGATIVE=0; \
				}

//Y_GPIO output  X_GPIO input
#define X_GPIO_STANDBY()	{PB_DDR2=IO_AS_OUTPUT;\
					PB_CR12=1;PB_CR22=0;\
					TOURCH_PANEL_X_POSITIVE=1;\
					PB_DDR3=IO_AS_OUTPUT;\
					PB_CR13=0;PB_CR23=0;\
					TOURCH_PANEL_X_NEGATIVE=0;\
				}

#define		Read_X_Standby()	{X_GPIO_STANDBY();\
								X_ADC_ENABLE();\
								}
#define		Read_Y_Standby()	{Y_GPIO_STANDBY();\
								Y_ADC_ENABLE();\
								}


//x_ADC output  y_ADC output     X_GPIO output    Y_GPIO output
#define		Clear_ALL_State()	{PB_DDR2=IO_AS_OUTPUT;PB_DDR3=IO_AS_OUTPUT;\
			PB_DDR4=IO_AS_OUTPUT;PB_DDR5=IO_AS_OUTPUT;\
			PB_CR12=0;PB_CR13=0;PB_CR14=0;PB_CR15=0;\
			TOURCH_PANEL_X_NEGATIVE=0; TOURCH_PANEL_Y_NEGATIVE=0;\
			TOURCH_PANEL_X_POSITIVE=0; TOURCH_PANEL_Y_POSITIVE=0;\
		}

extern void  TouchPanel_Initial(void);
extern void TouchKey_ScanArthimetic(void);
extern uword GetTouchPanel_Y_Position(void);
extern uword GetTouchPanel_X_Position(void);
#endif
extern void Touch_Key_Scan(void);


#endif

